//
//  PABankCard.m
//  PAMobileWallet
//
//  Created by Pay_SMP002 on 13-7-10.
//  Copyright (c) 2013年 平安付. All rights reserved.
//

#import "PABankCard.h"

@implementation PABankCard

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        self.backgroundColor = [UIColor clearColor];
        nMode = BANKCARDMODE_Defalut;

        cardImageView = [[UIImageView alloc] initWithFrame:self.bounds];
        [self addSubview:cardImageView];

        CGSize size = frame.size;
        CGFloat x, y, w, h;
        CGFloat space = size.width / 50;

        h = 30;
        y = size.height - 50;
        w = size.width - 4 * space;
        x = space;

        cardNOLabel = [[UILabel alloc] initWithFrame:CGRectMake(x, y, w, h)];
        cardNOLabel.backgroundColor = [UIColor clearColor];
        cardNOLabel.textColor = [UIColor whiteColor];
        cardNOLabel.text = @"6221 0000 0000 0000 999";
        cardNOLabel.adjustsFontSizeToFitWidth = YES;
        [cardImageView addSubview:cardNOLabel];

        w = size.width;
        h = 7;
        x = 0;
        y = size.height - h / 2;
        lineImageView = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, w, h)];
        lineImageView.image = [UIImage imageNamed:@"account_cardsink.png"];
        [self addSubview:lineImageView];
        lineImageView.hidden = YES;
        
    }
    return self;
}

- (void)setMode:(BANKCARDMODE)mode {
    nMode = mode;

    switch (nMode) {
        case BANKCARDMODE_Defalut:
            cardImageView.frame = self.bounds;
            lineImageView.hidden = YES;
            break;
        case BANKCARDMODE_Line:
            cardImageView.frame = CGRectMake(10, 0, self.bounds.size.width - 20, self.bounds.size.height);
            lineImageView.hidden = NO;
            break;
        default:
            break;
    }
}

- (void)setBankCardImage:(UIImage *)image {
    cardImageView.image = image;
}
- (void)setBankCardNO:(NSString *)cardNO {
    if (cardNO) {
        cardNOLabel.text = cardNO;
    }
}

@end
